package com.hb.software.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.*;


import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
 * 基础实体类
 *
 * @author zpf
 */

@MappedSuperclass
//@Access(value = AccessType.FIELD)
public class BaseEntity<PK extends Serializable> extends BaseDomain {

    /**
     *
     */
    private static final long serialVersionUID = -6163675075289529459L;


    //    @Id
//    @GeneratedValue(strategy = GenerationType.AUTO)
    private long id;

    //    @Column(updatable = false)
    private Date createDate;
    private Date modifyDate;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public Date getModifyDate() {
        return modifyDate;
    }

    public void setModifyDate(Date modifyDate) {
        this.modifyDate = modifyDate;
    }

    @Override
    public boolean equals(Object obj) {
        if (null != obj) {
            if (obj instanceof BaseEntity) {
                @SuppressWarnings("unchecked")
                BaseEntity<PK> domain = (BaseEntity<PK>) obj;
                if (this.id == domain.id) {
                    return true;
                }
            }
        }
        return false;
    }

    @Override
    public int hashCode() {
        return HashCodeBuilder.reflectionHashCode(this.id);
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
    }
}

